from pandac.PandaModules import Point3
from direct.actor import Actor
from direct.interval.IntervalGlobal import *
import pmcore.basecom

class PMComponent (pmcore.basecom.BaseComponent):
    
    def __init__(self):
        pmcore.basecom.BaseComponent.__init__(self)
        self.name = "Sample Scene"
        
    def after_direct_import(self):
        self.environ = loader.loadModel("models/environment")
        self.environ.reparentTo(render)
        self.environ.setScale(0.25,0.25,0.25)
        self.environ.setPos(-8,42,0)
        self.pandaActor = Actor.Actor("models/panda-model",{"walk":"models/panda-walk4"})
        self.pandaActor.setScale(0.005,0.005,0.005)
        self.pandaActor.reparentTo(render)
        self.pandaActor.loop("walk")

        self.pandaPosInterval1 = self.pandaActor.posInterval(13,Point3(0,-10,0), startPos=Point3(0,10,0))
        self.pandaPosInterval2 = self.pandaActor.posInterval(13,Point3(0,10,0), startPos=Point3(0,-10,0))
        self.pandaHprInterval1 = self.pandaActor.hprInterval(3,Point3(180,0,0), startHpr=Point3(0,0,0))
        self.pandaHprInterval2 = self.pandaActor.hprInterval(3,Point3(0,0,0), startHpr=Point3(180,0,0))

        self.pandaPace = Sequence(self.pandaPosInterval1, self.pandaHprInterval1,
            self.pandaPosInterval2, self.pandaHprInterval2, name = "pandaPace")
        self.pandaPace.loop()
